﻿using System;
using System.Collections.Generic;
using System.IO;

class SortText
{
    static void Main()
    {
        List<string> strList = new List<string>();
        StreamReader readFile = new StreamReader("unsorted.txt");
        using (readFile)
        {
            string readedLine = readFile.ReadLine();
            Console.WriteLine("The unsorted file is:");
            while (readedLine != null)
            {
                strList.Add(readedLine);
                Console.WriteLine(readedLine);
                readedLine = readFile.ReadLine();
            }
        }
        Console.WriteLine();
        strList.Sort();
        StreamWriter writeFile = new StreamWriter("sorted.txt");
        using (writeFile)
        {
            string lineToWrite = "";
            Console.WriteLine("The sorted file is:");
            for (int index = 0; index < strList.Count; index++)
            {
                lineToWrite = strList[index];
                writeFile.WriteLine(lineToWrite);
                Console.WriteLine(lineToWrite);
            }
        }
    }
}

